package 数列.泰波那契数列;

/**
 * TODO
 *
 * @className: ti
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-04-27 18:30
 **/
public class ti {
    public static void main(String[] args) {
        System.out.println(tribonacci(0));
    }

    public static int tribonacci(int n) {

        int[] arr = new int[n+3];
        arr[0] = 0;
        arr[1] = 1;
        arr[2] = 1;
        if (n < 3){
            return arr[n];
        }
        for(int i = 3; i<= arr.length-1; ++i){
            arr[i] = arr[i-1] + arr[i-2] + arr[i-3];
        }
        return arr[n];
    }
}
